package com.wjbgn.bsolver.server.convert;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wjbgn.bsolver.server.dto.BugAnswerAcceptRejectDTO;
import com.wjbgn.bsolver.server.entity.BugAnswerAcceptRejectDO;
import com.wjbgn.stater.util.BeanCopierUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Description: bug回复的用户采纳和无用记录
 * Create Date: 2022-05-11T14:01:17.965
 * @author wjbgn
 * @version 1.0
 */
@Component
public class BugAnswerAcceptRejectDoConvert {

    /**
     * DtoToDo
     *
     * @param bugAnswerAcceptRejectDTO
     * @return
     */
    public static BugAnswerAcceptRejectDO dtoToDo(BugAnswerAcceptRejectDTO bugAnswerAcceptRejectDTO) {
            BugAnswerAcceptRejectDO bugAnswerAcceptRejectDO = new BugAnswerAcceptRejectDO();
        BeanCopierUtil.copy(bugAnswerAcceptRejectDTO, bugAnswerAcceptRejectDO);
        return bugAnswerAcceptRejectDO;
    }

    /**
     * DoToDto
     *
     * @param bugAnswerAcceptRejectDO
     * @return
     */
    public static BugAnswerAcceptRejectDTO doToDto(BugAnswerAcceptRejectDO bugAnswerAcceptRejectDO) {
            BugAnswerAcceptRejectDTO bugAnswerAcceptRejectDTO = new BugAnswerAcceptRejectDTO();
        BeanCopierUtil.copy(bugAnswerAcceptRejectDO, bugAnswerAcceptRejectDTO);
        return bugAnswerAcceptRejectDTO;
    }

    /**
     * Page<DO> to Page<DTO>
     *
     * @param pageDO
     * @return
     */
    public static Page<BugAnswerAcceptRejectDTO> pageConvert(Page<BugAnswerAcceptRejectDO> pageDO) {
        List<BugAnswerAcceptRejectDTO> list = listConvert(pageDO.getRecords());
        Page<BugAnswerAcceptRejectDTO> page = new Page<>(pageDO.getCurrent(), pageDO.getSize(), pageDO.getTotal());
        page.setRecords(list);
        return page;
    }

    /**
     * list<DO> to list<DTO>
     *
     * @param listDO
     * @return
     */
    public static List<BugAnswerAcceptRejectDTO> listConvert(List<BugAnswerAcceptRejectDO> listDO) {
        List<BugAnswerAcceptRejectDTO> list = new ArrayList<>();
            BugAnswerAcceptRejectDTO bugAnswerAcceptRejectDTO;
        for (BugAnswerAcceptRejectDO bugAnswerAcceptRejectDO : listDO) {
                bugAnswerAcceptRejectDTO = new BugAnswerAcceptRejectDTO();
            BeanCopierUtil.copy(bugAnswerAcceptRejectDO, bugAnswerAcceptRejectDTO);
            list.add(bugAnswerAcceptRejectDTO);
        }
        return list;
    }
}